﻿<r:RibbonWindow x:Class="EDMDesigner.Host.EDMDesignerWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:system="clr-namespace:System;assembly=mscorlib"
    xmlns:windowsBase="clr-namespace:System.ComponentModel;assembly=WindowsBase"
    xmlns:local="clr-namespace:EDMDesigner.Host"
    xmlns:edmDesignerBindindingConverter="clr-namespace:EDMDesigner.Designer.BindingConverter;assembly=EDMDesigner"
    xmlns:uiBusiness="clr-namespace:EDMDesigner.UIBusiness;assembly=UIBusiness"
    xmlns:uiBusinessCSDLType="clr-namespace:EDMDesigner.UIBusiness.CSDL.Type;assembly=UIBusiness"
    xmlns:edmDesignerControls="clr-namespace:EDMDesigner.Designer.Controls;assembly=EDMDesigner"
    xmlns:edmDesignerControlsCSDLType="clr-namespace:EDMDesigner.Designer.Controls.CSDLType;assembly=EDMDesigner"
    xmlns:edmDesignerControlsMenu="clr-namespace:EDMDesigner.Designer.Controls.Menu;assembly=EDMDesigner"
    xmlns:edmDesignerControlsMapping="clr-namespace:EDMDesigner.Designer.Controls.Mapping;assembly=EDMDesigner"
    xmlns:wpfTabControl="clr-namespace:Wpf.Controls;assembly=Wpf.TabControl"
    xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
    Title="{x:Static local:EDMDesignerWindow.WindowTitle}"
    Height="600"
    Width="800"
    WindowState="Maximized"
    Background="White">

    <Window.Resources>
        <edmDesignerBindindingConverter:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
        <edmDesignerBindindingConverter:BoolToFontWeightConverter x:Key="BoolToFontWeightConverter" />

        <ObjectDataProvider x:Key="odp" ObjectType="{x:Type uiBusiness:EDMController}" MethodName="CreateView" />
        <CollectionViewSource x:Key="entityTypesCollectionView"
                          Source="{Binding Source={StaticResource odp}, Path=CSDL.EntityTypes}">
            <CollectionViewSource.SortDescriptions>
                <windowsBase:SortDescription PropertyName="Name" />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>
        <CollectionViewSource x:Key="entitySetCollectionView"
                          Source="{Binding Source={StaticResource odp}, Path=CSDL.EntityTypes}">
            <CollectionViewSource.SortDescriptions>
                <windowsBase:SortDescription PropertyName="Name" />
            </CollectionViewSource.SortDescriptions>
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="EntitySetName" />
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>
        <CollectionViewSource x:Key="complexTypesCollectionView"
                          Source="{Binding Source={StaticResource odp}, Path=CSDL.ComplexTypes}">
            <CollectionViewSource.SortDescriptions>
                <windowsBase:SortDescription PropertyName="Name" />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>
        <CollectionViewSource x:Key="csdlFunctionsCollectionView"
                          Source="{Binding Source={StaticResource odp}, Path=CSDL.Functions}">
            <CollectionViewSource.SortDescriptions>
                <windowsBase:SortDescription PropertyName="Name" />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>
        <CollectionViewSource x:Key="tablesCollectionView"
                          Source="{Binding Source={StaticResource odp}, Path=SSDL.Tables}">
            <CollectionViewSource.SortDescriptions>
                <windowsBase:SortDescription PropertyName="Name" />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>
        <CollectionViewSource x:Key="ssdlFunctionsCollectionView"
                          Source="{Binding Source={StaticResource odp}, Path=SSDL.Functions}">
            <CollectionViewSource.SortDescriptions>
                <windowsBase:SortDescription PropertyName="Name" />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>

        <edmDesignerControlsMenu:ContextMenu x:Key="CSDLTypeContextMenu">
            <!--<edmDesignerControlsMenu:MenuItem x:Name="renameMenuItem" Header="{x:Static local:EDMDesignerWindow.RenameText}" Command="{x:Static local:EDMDesignerWindow.RenameCommand}" InputGestureText="F2" />-->
            <edmDesignerControlsMenu:MenuItem x:Name="deleteMenuItem" Header="{x:Static local:EDMDesignerWindow.DeleteText}" Command="{x:Static local:EDMDesignerWindow.DeleteCommand}" InputGestureText="Del">
                <edmDesignerControlsMenu:MenuItem.Icon>
                    <Image Source="pack://application:,,,/EDMDesigner;component/Controls/CSDLType/Resources/Delete.png" Width="16" Height="16" />
                </edmDesignerControlsMenu:MenuItem.Icon>
            </edmDesignerControlsMenu:MenuItem>
            <edmDesignerControlsMenu:MenuSeparator/>
            <edmDesignerControlsMenu:MenuItem x:Name="propertiesMenuItem" Header="{x:Static local:EDMDesignerWindow.PropertiesText}" Command="{x:Static local:EDMDesignerWindow.PropertiesCommand}" InputGestureText="F4" />
            <edmDesignerControlsMenu:MenuItem x:Name="mappingMenuItem" Header="{x:Static local:EDMDesignerWindow.MappingText}" Command="{x:Static local:EDMDesignerWindow.MappingCommand}" InputGestureText="Ctrl+Shift+M" />
            <edmDesignerControlsMenu:MenuSeparator />
            <edmDesignerControlsMenu:MenuItem x:Name="showTabsMenuItem" Header="{x:Static local:EDMDesignerWindow.ShowTabsText}" Command="{x:Static local:EDMDesignerWindow.ShowTabsCommand}">
                <edmDesignerControlsMenu:MenuItem.ItemTemplate>
                    <DataTemplate>
                        <MenuItem Command="{x:Static local:EDMDesignerWindow.ShowTabsItemCommand}" CommandParameter="{Binding}">
                            <MenuItem.Header>
                                <Grid Background="DarkGray" Margin="-30,0,-120,0">
                                    <StackPanel>
                                        <TextBlock Margin="10,5" x:Name="tabTextBlock" Text="{Binding Name}" Background="DarkGray" Foreground="White" FontWeight="Bold" />
                                        <Grid Margin="2">
                                            <edmDesignerControls:DesignerCanvasPreview x:Name="tabDesignerCanvas" Width="150" Height="100" DesignerView="{Binding}" />
                                            <Grid Opacity="0" Background="White" Width="150" Height="100" />
                                        </Grid>
                                    </StackPanel>
                                </Grid>
                            </MenuItem.Header>
                        </MenuItem>
                    </DataTemplate>
                </edmDesignerControlsMenu:MenuItem.ItemTemplate>
            </edmDesignerControlsMenu:MenuItem>
        </edmDesignerControlsMenu:ContextMenu>

        <InputBindingCollection x:Key="ContextMenuKeyBindings">
            <KeyBinding Key="Delete" Command="{x:Static local:EDMDesignerWindow.DeleteCommand}" />
            <KeyBinding Key="F4" Command="{x:Static local:EDMDesignerWindow.PropertiesCommand}" />
            <KeyBinding Key="M" Modifiers="CTRL+Shift" Command="{x:Static local:EDMDesignerWindow.MappingCommand}" />
        </InputBindingCollection>

        <!--I use http://www.orbifold.net/default/?p=702-->
        <ControlTemplate x:Key="VerticalTab" TargetType="{x:Type TabItem}">
            <Grid SnapsToDevicePixels="True">
                <Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="2,1,1,0" Padding="{TemplateBinding Padding}">
                    <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}" x:Name="Content" VerticalAlignment="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}" Content="{TemplateBinding Header}" ContentSource="Header" ContentTemplate="{TemplateBinding HeaderTemplate}" RecognizesAccessKey="True"/>
                </Border>
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" TargetName="Bd">
                        <Setter.Value>
                            <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
                                <GradientStop Color="#FFEAF6FD" Offset="0"/>
                                <GradientStop Color="#FFA7D9F5" Offset="1"/>
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                </Trigger>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Panel.ZIndex" Value="1"/>
                    <Setter Property="Background" TargetName="Bd" Value="LightGray">
                    </Setter>
                </Trigger>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsSelected" Value="False"/>
                        <Condition Property="IsMouseOver" Value="True"/>
                    </MultiTrigger.Conditions>
                    <Setter Property="BorderThickness" TargetName="Bd" Value="3"/>
                    <Setter Property="BorderBrush" TargetName="Bd" Value="#FF2B4E5B"/>
                </MultiTrigger>
                <Trigger Property="TabStripPlacement" Value="Bottom">
                    <Setter Property="BorderThickness" TargetName="Bd" Value="1,0,1,1"/>
                </Trigger>
                <Trigger Property="TabStripPlacement" Value="Left">
                    <Setter Property="BorderThickness" TargetName="Bd" Value="1,1,0,1"/>
                </Trigger>
                <Trigger Property="TabStripPlacement" Value="Right">
                    <Setter Property="BorderThickness" TargetName="Bd" Value="0,1,1,1"/>
                </Trigger>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsSelected" Value="True"/>
                        <Condition Property="TabStripPlacement" Value="Top"/>
                    </MultiTrigger.Conditions>
                    <Setter Property="Margin" Value="-4,0,0,0"/>
                    <Setter Property="Margin" TargetName="Content" Value="0,0,0,1"/>
                </MultiTrigger>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsSelected" Value="True"/>
                        <Condition Property="TabStripPlacement" Value="Bottom"/>
                    </MultiTrigger.Conditions>
                    <Setter Property="Margin" Value="0,0,0,-4"/>
                    <Setter Property="Margin" TargetName="Content" Value="0,1,0,0"/>
                </MultiTrigger>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsSelected" Value="True"/>
                        <Condition Property="TabStripPlacement" Value="Left"/>
                    </MultiTrigger.Conditions>
                    <Setter Property="Margin" Value="-4,0,0,0"/>
                    <Setter Property="Margin" TargetName="Content" Value="0,0,1,0"/>
                </MultiTrigger>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsSelected" Value="True"/>
                        <Condition Property="TabStripPlacement" Value="Right"/>
                    </MultiTrigger.Conditions>
                    <Setter Property="Margin" Value="0,0,-4,0"/>
                    <Setter Property="Margin" TargetName="Content" Value="1,0,0,0"/>
                </MultiTrigger>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="BorderBrush" TargetName="Bd" Value="#FFC9C7BA"/>
                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                </Trigger>
                <Trigger Property="IsSelected" Value="False">
                    <Setter Property="Margin" Value="0,0,0,0"/>
                    <Setter Property="Background" Value="#EEEEEE"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Window.Resources>

    <DockPanel LastChildFill="true">

        <r:Ribbon x:Name="ribbon" DockPanel.Dock="Top" Title="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=Title}">

            <r:Ribbon.Resources>
                <ResourceDictionary>
                    <r:RibbonCommand x:Key="newCommand" LabelTitle="{x:Static local:EDMDesignerWindow.NewText}" ToolTipTitle="{x:Static local:EDMDesignerWindow.NewText}" SmallImageSource="Resources/New.png" LargeImageSource="Resources/New.png" Executed="newCommand_Executed" />
                    <r:RibbonCommand x:Key="openCommand" LabelTitle="{x:Static local:EDMDesignerWindow.OpenText}" ToolTipTitle="{x:Static local:EDMDesignerWindow.OpenText}" SmallImageSource="Resources/Open.png" LargeImageSource="Resources/Open.png" Executed="openCommand_Executed" />
                    <r:RibbonCommand x:Key="saveCommand" LabelTitle="{x:Static local:EDMDesignerWindow.SaveText}" ToolTipTitle="{x:Static local:EDMDesignerWindow.SaveText}" SmallImageSource="Resources/Save.png" LargeImageSource="Resources/Save.png" Executed="saveCommand_Executed"/>
                    <r:RibbonCommand x:Key="saveAsCommand" LabelTitle="{x:Static local:EDMDesignerWindow.SaveAsText}" ToolTipTitle="{x:Static local:EDMDesignerWindow.SaveAsText}" SmallImageSource="Resources/SaveAs.png" LargeImageSource="Resources/SaveAs.png" Executed="saveAsCommand_Executed"/>

            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Silver.xaml" />
            </ResourceDictionary.MergedDictionaries>
                </ResourceDictionary>
            </r:Ribbon.Resources>

            <r:Ribbon.ApplicationMenu>
                <r:RibbonApplicationMenu>
                    <r:RibbonApplicationMenuItem Command="{StaticResource newCommand}" />
                    <r:RibbonApplicationMenuItem Command="{StaticResource openCommand}" />
                    <r:RibbonApplicationMenuItem Command="{StaticResource saveCommand}" />
                    <r:RibbonApplicationMenuItem Command="{StaticResource saveAsCommand}" />
                </r:RibbonApplicationMenu>
            </r:Ribbon.ApplicationMenu>

            <r:Ribbon.QuickAccessToolBar>
                <r:RibbonQuickAccessToolBar>
                    <r:RibbonButton r:RibbonQuickAccessToolBar.Placement="InToolBar" Margin="0,2,0,0" Command="{StaticResource openCommand}"  />
                    <r:RibbonButton r:RibbonQuickAccessToolBar.Placement="InToolBar" Margin="0,2,0,0" Command="{StaticResource saveCommand}"  />
                </r:RibbonQuickAccessToolBar>
            </r:Ribbon.QuickAccessToolBar>

            <r:RibbonTab Label="{x:Static local:EDMDesignerWindow.EditText}">
                <r:RibbonTab.Groups>
                    <r:RibbonGroup>
                        <r:RibbonGroup.GroupSizeDefinitions>
                            <r:RibbonGroupSizeDefinitionCollection>
                                <r:RibbonGroupSizeDefinition>
                                    <!-- Control sizes: S,S,S -->
                                    <r:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="True"/>
                                    <r:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="True"/>
                                    <r:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="True"/>
                                </r:RibbonGroupSizeDefinition>
                            </r:RibbonGroupSizeDefinitionCollection>
                        </r:RibbonGroup.GroupSizeDefinitions>
                        <r:RibbonButton>
                            <r:RibbonButton.Command>
                                <r:RibbonCommand x:Name="cutCommand" LabelTitle="{x:Static edmDesignerControlsCSDLType:TypeBaseDesigner.CutText}" ToolTipTitle="{x:Static edmDesignerControlsCSDLType:TypeBaseDesigner.CutText}" ToolTipDescription="(CTRL + X)" SmallImageSource="Resources/Cut.png" LargeImageSource="Resources/Cut.png" />
                            </r:RibbonButton.Command>
                        </r:RibbonButton>
                        <r:RibbonButton>
                            <r:RibbonButton.Command>
                                <r:RibbonCommand x:Name="copyCommand" LabelTitle="{x:Static edmDesignerControlsCSDLType:TypeBaseDesigner.CopyText}" ToolTipTitle="{x:Static edmDesignerControlsCSDLType:TypeBaseDesigner.CopyText}" ToolTipDescription="(CTRL + C)" SmallImageSource="Resources/Copy.png" LargeImageSource="Resources/Copy.png" />
                            </r:RibbonButton.Command>
                        </r:RibbonButton>
                        <r:RibbonButton>
                            <r:RibbonButton.Command>
                                <r:RibbonCommand x:Name="pasteCommand" LabelTitle="{x:Static edmDesignerControlsCSDLType:TypeBaseDesigner.PasteText}" ToolTipTitle="{x:Static edmDesignerControlsCSDLType:TypeBaseDesigner.PasteText}" ToolTipDescription="(CTRL + V)" SmallImageSource="Resources/Paste.png" LargeImageSource="Resources/Paste.png" />
                            </r:RibbonButton.Command>
                        </r:RibbonButton>
                    </r:RibbonGroup>
                </r:RibbonTab.Groups>
            </r:RibbonTab>

        </r:Ribbon>

        <Grid Background="White">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="300"/>
            </Grid.ColumnDefinitions>

            <wpfTabControl:TabControl x:Name="designerTab" ItemsSource="{Binding Source={StaticResource odp}, Path=DesignerViews}" Grid.Column="0" Margin="0,0,2,0" MouseLeave="DesignerTab_MouseLeave" NewTabItem="designerTab_NewTabItem">
                <wpfTabControl:TabControl.ItemTemplate>
                    <DataTemplate>
                        <edmDesignerControls:EditableTextBlock x:Name="tabNameEditableTextBlock" Text="{Binding Name, Mode=TwoWay}"/>
                    </DataTemplate>
                </wpfTabControl:TabControl.ItemTemplate>
                <!--<wpfTabControl:TabControl.ContentTemplate>
                <DataTemplate>
                    <ScrollViewer x:Name="designerScrollViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
                        <edmDesignerControls:DesignerCanvas x:Name="designerSurface" AllowDrop="True" EDMView="{Binding Source={StaticResource odp}}" DesignerView="{Binding}" Background="White" />
                    </ScrollViewer>
                </DataTemplate>
            </wpfTabControl:TabControl.ContentTemplate>-->
            </wpfTabControl:TabControl>
            <GridSplitter Width="2" BorderBrush="DarkGray" Margin="0,0,-1,0"/>
            <TabControl x:Name="toolBoxTabControl" Grid.Column="1" IsSynchronizedWithCurrentItem="True" HorizontalAlignment="Stretch" TabStripPlacement="Right">
                <TabControl.Resources>
                    <Style TargetType="{x:Type TabItem}">
                        <Setter Property="Padding" Value="5" />
                        <Setter Property="HeaderTemplate">
                            <Setter.Value>
                                <DataTemplate>
                                    <ContentPresenter Content="{TemplateBinding Property=ContentControl.Content}">
                                        <ContentPresenter.LayoutTransform>
                                            <RotateTransform Angle="90" />
                                        </ContentPresenter.LayoutTransform>
                                    </ContentPresenter>
                                </DataTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </TabControl.Resources>

                <TabItem Header="{x:Static local:EDMDesignerWindow.ModelBrowserTabText}" Template="{StaticResource VerticalTab}">
                    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                        <Grid x:Name="toolbox" Grid.Column="0" Background="LightGray">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <edmDesignerControls:ToolBoxExpander Header="{x:Static local:EDMDesignerWindow.ModelBrowserTabCSDLGroupText}" Grid.Row="0" IsExpanded="True" Margin="5,5,5,5" Background="Gray">
                                <ScrollViewer VerticalScrollBarVisibility="Auto">
                                    <edmDesignerControls:ToolBoxGrid LastRowMinHeight="65">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                        <edmDesignerControls:ToolBoxExpander Grid.Row="0" Header="{x:Static local:EDMDesignerWindow.ModelBrowserTabCSDLGroupEntityTypeGroupText}" Margin="5,5,5,5" Padding="2,2,2,2" IsExpanded="True" Background="DarkGray">
                                            <Grid Background="LightGray">
                                                <Grid>
                                                    <RadioButton x:Name="groupRadioButton" Margin="2,2,2,0" Content="{x:Static local:EDMDesignerWindow.ModelBrowserTabCSDLGroupEntityTypeGroupRadioGroupByEntitySetText}" IsChecked="True" />
                                                    <RadioButton x:Name="hierarchyRadioButton" Margin="2,25,2,0" Content="{x:Static local:EDMDesignerWindow.ModelBrowserTabCSDLGroupEntityTypeGroupRadioEntitySetHierarchyText}" />
                                                </Grid>
                                                <edmDesignerControls:InputBindingsContener Margin="0,50,0,2">
                                                    <ListView x:Name="entityTypesListView" Margin="2,0,2,0" MinHeight="20" Visibility="{Binding ElementName=groupRadioButton, Path=IsChecked, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" ItemsSource="{Binding Source={StaticResource entitySetCollectionView}}" ItemTemplate="{DynamicResource CSDLTypeItemTemplate}" SelectionMode="Single" ContextMenu="{StaticResource CSDLTypeContextMenu}" edmDesignerControls:InputBindingsContener.InputBindingsCollection="{StaticResource ContextMenuKeyBindings}" SelectionChanged="EntityTypesListView_SelectionChanged" GotFocus="EntityTypesListView_GotFocus" >
                                                        <ListView.GroupStyle>
                                                            <GroupStyle>
                                                                <GroupStyle.HeaderTemplate>
                                                                    <DataTemplate>
                                                                        <Grid Background="LightGray">
                                                                            <TextBlock Text="{Binding Name}" />
                                                                        </Grid>
                                                                    </DataTemplate>
                                                                </GroupStyle.HeaderTemplate>
                                                            </GroupStyle>
                                                        </ListView.GroupStyle>
                                                    </ListView>
                                                </edmDesignerControls:InputBindingsContener>
                                                <Grid Margin="0,42,0,2" Visibility="{Binding ElementName=hierarchyRadioButton, Path=IsChecked, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
                                                    <ComboBox x:Name="hierarchyFilterComboBox" Margin="2,5,2,0" Background="White" Height="20" VerticalAlignment="Top" ItemsSource="{Binding Source={StaticResource entityTypesCollectionView}}" SelectedValue="{Binding Source={StaticResource odp}, Path=CSDL.HierarchyType}" DisplayMemberPath="Name" />
                                                    <edmDesignerControls:InputBindingsContener>
                                                        <TreeView x:Name="hierarchyFilterTreeView" Margin="2,30,2,0" MinHeight="20" ItemsSource="{Binding Source={StaticResource odp}, Path=CSDL.HierarchyTypes, Mode=OneWay}" ContextMenu="{StaticResource CSDLTypeContextMenu}" edmDesignerControls:InputBindingsContener.InputBindingsCollection="{StaticResource ContextMenuKeyBindings}" SelectedItemChanged="HierarchyFilterTreeView_SelectedItemChanged" GotFocus="HierarchyFilterTreeView_GotFocus">
                                                            <TreeView.ItemTemplate>
                                                                <HierarchicalDataTemplate DataType="{x:Type uiBusinessCSDLType:UIEntityType}" ItemsSource="{Binding SubEntityTypes}" >
                                                                    <edmDesignerControls:CSDLTypeItem Text="{Binding Name}" UIType="{Binding Mode=OneTime}" FontWeight="{Binding Bold, Converter={StaticResource BoolToFontWeightConverter}, Mode=OneTime}"/>
                                                                </HierarchicalDataTemplate>
                                                            </TreeView.ItemTemplate>
                                                            <TreeView.ItemContainerStyle>
                                                                <Style>
                                                                    <Setter Property="TreeViewItem.IsExpanded" Value="true"/>
                                                                </Style>
                                                            </TreeView.ItemContainerStyle>
                                                        </TreeView>
                                                    </edmDesignerControls:InputBindingsContener>
                                                </Grid>
                                            </Grid>
                                        </edmDesignerControls:ToolBoxExpander>
                                        <GridSplitter Grid.Row="0" Height="2" BorderBrush="Gray" Margin="0,1,0,1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
                                        <edmDesignerControls:ToolBoxExpander Grid.Row="1" Header="{x:Static local:EDMDesignerWindow.ModelBrowserTabCSDLGroupComplexTypeGroupText}" Margin="5,1,5,5" Padding="2,2,2,2" IsExpanded="True" Background="DarkGray">
                                            <edmDesignerControls:InputBindingsContener Margin="2,2,2,2" Background="LightGray">
                                                <ListView x:Name="complexTypesListView" Margin="2,2,2,2" MinHeight="20" ItemsSource="{Binding Source={StaticResource complexTypesCollectionView}}" ItemTemplate="{DynamicResource CSDLTypeItemTemplate}" SelectionMode="Single" ContextMenu="{StaticResource CSDLTypeContextMenu}" edmDesignerControls:InputBindingsContener.InputBindingsCollection="{StaticResource ContextMenuKeyBindings}" SelectionChanged="ComplexTypesListView_SelectionChanged" GotFocus="ComplexTypesListView_GotFocus" />
                                            </edmDesignerControls:InputBindingsContener>
                                        </edmDesignerControls:ToolBoxExpander>
                                        <GridSplitter Grid.Row="1" Height="2" BorderBrush="Gray" Margin="0,1,0,1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
                                        <edmDesignerControls:ToolBoxExpander Grid.Row="2" Header="{x:Static local:EDMDesignerWindow.ModelBrowserTabCSDLGroupFunctionsGroupText}" Margin="5,1,5,5" Padding="2,2,2,2" IsExpanded="True" Background="DarkGray">
                                            <Grid Margin="2,2,2,2" Background="LightGray">
                                                <ListView Margin="2,2,2,2" MinHeight="20" ItemsSource="{Binding Source={StaticResource csdlFunctionsCollectionView}}" DisplayMemberPath="Name">
                                                </ListView>
                                            </Grid>
                                        </edmDesignerControls:ToolBoxExpander>
                                    </edmDesignerControls:ToolBoxGrid>
                                </ScrollViewer>
                            </edmDesignerControls:ToolBoxExpander>
                            <GridSplitter Grid.Row="0" Height="2" BorderBrush="Gray" Margin="0,1,0,1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
                            <edmDesignerControls:ToolBoxExpander Header="{x:Static local:EDMDesignerWindow.ModelBrowserTabSSDLGroupText}" Grid.Row="1" Margin="5,1,5,5" IsExpanded="True" Background="Gray">
                                <ScrollViewer VerticalScrollBarVisibility="Auto">
                                    <edmDesignerControls:ToolBoxGrid LastRowMinHeight="65">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                        <edmDesignerControls:ToolBoxExpander Grid.Row="0" Header="{x:Static local:EDMDesignerWindow.ModelBrowserTabSSDLGroupEntityTypeGroupText}" Margin="5,1,5,5" Padding="2,2,2,2" IsExpanded="True" Background="DarkGray">
                                            <Grid Margin="2,2,2,2" Background="LightGray">
                                                <ListView Margin="2,2,2,2" MinHeight="20" ItemsSource="{Binding Source={StaticResource tablesCollectionView}}" DisplayMemberPath="Name">
                                                </ListView>
                                            </Grid>
                                        </edmDesignerControls:ToolBoxExpander>
                                        <GridSplitter Grid.Row="0" Height="2" BorderBrush="Gray" Margin="0,1,0,1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
                                        <edmDesignerControls:ToolBoxExpander Grid.Row="1" Header="{x:Static local:EDMDesignerWindow.ModelBrowserTabSSDLGroupFunctionsGroupText}" Margin="5,1,5,5" Padding="2,2,2,2" IsExpanded="True" Background="DarkGray">
                                            <Grid Margin="2,2,2,2" Background="LightGray">
                                                <ListView Margin="2,2,2,2" MinHeight="20" ItemsSource="{Binding Source={StaticResource ssdlFunctionsCollectionView}}" DisplayMemberPath="Name">
                                                </ListView>
                                            </Grid>
                                        </edmDesignerControls:ToolBoxExpander>
                                    </edmDesignerControls:ToolBoxGrid>
                                </ScrollViewer>
                            </edmDesignerControls:ToolBoxExpander>
                            <GridSplitter Grid.Row="1" Height="2" BorderBrush="Gray" Margin="0,1,0,1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
                            <Grid Grid.Row="2" />
                        </Grid>
                    </ScrollViewer>
                </TabItem>
                <TabItem x:Name="propertiesTabItem" Header="{x:Static local:EDMDesignerWindow.TabPropertiesText}" Template="{StaticResource VerticalTab}">
                    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                        <edmDesignerControls:PropertyGrid x:Name="propertiesGrid" CSDL="{Binding Source={StaticResource odp}, Path=CSDL.CSDL}" HorizontalAlignment="Stretch" />
                    </ScrollViewer>
                </TabItem>
                <TabItem x:Name="mappingTabItem" Header="{x:Static local:EDMDesignerWindow.TabMappingText}" Template="{StaticResource VerticalTab}">
                    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                        <edmDesignerControlsMapping:Mapping x:Name="mapping" EDM="{Binding Source={StaticResource odp}, Path=EDM}"/>
                    </ScrollViewer>
                </TabItem>
            </TabControl>
        </Grid>
    </DockPanel>
</r:RibbonWindow>
